﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel.Channels;
using System.Text;
using System.Threading.Tasks;
using Wicresoft.EKA.Atrium.WCFWS.CMDBClassManager;

namespace Wicresoft.EKA.Atrium.WCFWS
{
    public class CMDBClassMgr
    {
        public ListClassesOutput ListClasses()
        {

            System.Net.ServicePointManager.ServerCertificateValidationCallback = TrustAllCertificatePolicy.CheckValidationResult;
            CMDBClassManager.AtriumClasses_PortTypeClient client = new CMDBClassManager.AtriumClasses_PortTypeClient();

            BindingElementCollection elements = client.Endpoint.Binding.CreateBindingElements();
            elements.Find<SecurityBindingElement>().IncludeTimestamp = false;
            client.Endpoint.Binding = new CustomBinding(elements);

            client.ClientCredentials.UserName.UserName = "Demo";
            client.ClientCredentials.UserName.Password = "Pass01!";

            //client.Endpoint

            return client.ListClasses(new CMDBClassManager.ListClasses()
               {
                   loginInfo = new CMDBClassManager.LoginInfo()
                   {
                       authentication = "Pass01!",
                       locale = "",
                       timeZone = ""
                   },
               });
        }
    }
}
